home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / vsoup11.zip / nntpcl.hh < prev    next >
Text File  |  1996-09-02  |  3KB  |  89 lines

  1. //  $Id: nntpcl.hh 1.10 1996/09/02 13:29:00 hardy Exp $
  2. //
  3. //  This progam/module was written by Hardy Griech based on ideas and
  4. //  pieces of code from Chin Huang (cthuang@io.org).  Bug reports should
  5. //  be submitted to rgriech@ibm.net.
  6. //
  7. //  This file is part of soup++ for OS/2.  Soup++ including this file
  8. //  is freeware.  There is no warranty of any kind implied.  The terms
  9. //  of the GNU Gernal Public Licence are valid for this piece of software.
  10. //
  11.  
  12.  
  13. #ifndef __NNTPCL_HH__
  14. #define __NNTPCL_HH__
  15.  
  16.  
  17. #include <assert.h>
  18. #include <stdio.h>
  19.  
  20. #include "socket.hh"
  21.  
  22.  
  23. //--------------------------------------------------------------------------------
  24. //
  25. //  Diverse NNTP-Fkts zur Klasse zusammengefaßt
  26. //
  27. //  Problem dieser Klasse ist:
  28. //  - die Zustände können/müssen von extern gesetzt werden
  29. //
  30. class TNntp:  private TSocket {
  31. public:
  32.     enum Res   { nok,ok,killed,notavail };    // nok must be 0, ok 1
  33.  
  34. public:
  35.     TNntp( void );
  36.     ~TNntp();
  37.     TNntp( const TNntp &right );          // copy constructor not allowed !
  38.     operator = (const TNntp &right);      // assignment operator not allowed !
  39.  
  40.     void  setHelper( void (*xref)(const char *xrefLine),
  41.              int (*killQ)(const char *groupName, const char *headerLine) );
  42.     Res  open( const char *nntpServer, const char *nntpUser, const char *nntpPasswd );
  43.     void close( int sendQuit=1 );
  44.     int  isReadOnly( void ) { return readOnly; }
  45.  
  46.     Res  getNewGroups( const char *nntpTimeFile, int changeFile );
  47.     Res  getOverview( long first, long last );
  48.     Res  setActGroup( const char *grpname, long &Cnt, long &lo, long &hi);
  49.     Res  nextArticle( long *next );
  50.     Res  postArticle( FILE *inf, size_t bytes );
  51.     Res  getArticle( void );
  52.  
  53.     FILE *getTmpF( void ) { assert( tmpF != NULL );  return tmpF; }
  54.  
  55.     void selectArticle( const char *grpname, long artNum=-1, int doKill=0 );
  56.     long article( void ) { return selArticle; }
  57.     long nntpArticle( void ) { return selNntpArticle; }
  58.     const char *groupName( void ) { return selGroup; }
  59.     const char *getLastErrMsg( void );
  60.  
  61.     static long getBytesRcvd( void );
  62.  
  63. private:
  64.     int  readOnly;
  65.     FILE *tmpF;
  66.     char *tmpN;
  67.     const char *actGroup;                                 // group activated at nntp server
  68.     const char *selGroup;
  69.     long selArticle;
  70.     long selNntpArticle;
  71.     long nntpGroupHi;
  72.     int  killEnabled;
  73.     char lastErrMsg[1000];                                // buffer for last error msg
  74.     const char *user;
  75.     const char *passwd;
  76.  
  77.     void (*xrefHook)( const char *xrefLine );             // hook for xref processing
  78.     int  (*killQHook)( const char *groupName,             // hook for killfile processing
  79.                const char *headerLine );  
  80.  
  81.     Res request( const char *request, char *reply, size_t replySize, int expReply );
  82.  
  83.     Res _getHead( void );
  84.     Res _getBody( void );
  85. };
  86.  
  87.     
  88. #endif   // __NNTPCL_HH__
  89.